import Vue from 'vue'
import VueRouter from 'vue-router'

import Home from '@/views/common/Home.vue'

Vue.use(VueRouter)

const routes = [
  // 若依的跳转路由
  // {
  //   path: '/redirect',
  //   component: Home,
  //   children: [
  //     {
  //       path: '/redirect/:path(.*)',
  //       component: () => import('@/views/redirect')
  //     }
  //   ]
  // },
  {
    path: '/login',
    component: () => import('@/views/login'),
    meta: { title: '登录' }
  },
  {
    path: '/register',
    component: () => import('@/views/register'),
    meta: { title: '注册' }
  },
  // 404
  {
    path: '*',
    redirect: '/404'
  },
  {
    path: '/',
    redirect: '/v'
  },
  // 带图片的顶部
  {
    path: '/v',
    name: 'background',
    // 懒加载 动态加载
    component: () => import('@/views/layout/fenqu.vue'),
    redirect: '/v/home',
    children: [
      {
        path: '/v/home',
        name: 'pilipili',
        component: () => import('@/views/common/Home.vue'),
        // meta: {
        //   title: '首页',
        //   name: "首页",
        //   content: "no-referrer", //解决跨域问题
        //   icon: 'dashboard',
        //   affix: true,
        // }
      },
      {
        path: '/404',
        component: () => import('@/views/404'),
        meta: { title: '404' }
      },
      {
        path: '/v/animation',
        component: () => import('@/views/fenqu/Live.vue'),
        meta: { title: '动画区' }
      },
    ]
  },
  // 不带图片的顶部
  {
    path: '/o',
    name: 'noBackground',
    component: () => import('@/views/layout/shipin.vue'),
    children: [
      {
        path: '/o/search',
        component: () => import('@/views/common/Search.vue'),
        meta: { title: '视频搜索页' }
      },
      {
        path: '/o/video/VideoDetail/:id',
        component: () => import('@/views/video/VideoDetail.vue'),
        meta: { title: '视频详情页' }
      },

      {
        path: '/o/live/LiveList',
        component: () => import('@/views/live/LiveList.vue'),
        meta: { title: '直播列表页' }
      },
      {
        path: '/o/live/PublishLive',
        component: () => import('@/views/live/PublishLive.vue'),
        meta: { title: '创建直播间页' }
      },
      {
        path: '/o/live/OpenLive',
        component: () => import('@/views/live/OpenLive.vue'),
        meta: { title: '主播播放页' }
      },
      {
        path: '/o/live/LiveDetail/:id',
        component: () => import('@/views/live/LiveDetail.vue'),
        meta: { title: '观众播放页' }
      },

      {
        path: '/o/chat/ChatList',
        component: () => import('@/views/chat/ChatList.vue'),
        meta: { title: '聊天室列表页' }
      },
      {
        path: '/o/chat/PublishChat',
        component: () => import('@/views/chat/PublishChat.vue'),
        meta: { title: '创建聊天室页' }
      },
      {
        path: '/o/chat/MyChat',
        component: () => import('@/views/chat/MyChat.vue'),
        meta: { title: '当前用户的聊天室列表页' }
      },

      {
        path: '/o/vip/vipPay',
        component: () => import('@/views/vip/vipPay.vue'),
        meta: { title: 'vip购买页面' }
      },
      {
        path: '/o/vip/paySuccess',
        component: () => import('@/views/vip/paySuccess.vue'),
        meta: { title: '支付成功页面' }
      },
      {
        path: '/o/vip/vipCenter',
        component: () => import('@/views/vip/vipCenter.vue'),
        meta: { title: '会员中心' }
      },

    ]
  },
  // 用户中心
  {
    path: '/c',
    name: 'userCenter',
    // 懒加载 动态加载
    component: () => import('@/views/layout/center.vue'),
    children: [
      {
        path: '/c/user/userCenter',
        component: () => import('@/views/user/userCenter.vue'),
        meta: { title: '我的空间' }
      },
      {
        path: '/c/user/userFollow',
        component: () => import('@/views/user/userFollow.vue'),
        meta: { title: '我的关注' }
      },
      {
        path: '/c/user/userFans',
        component: () => import('@/views/user/userFans.vue'),
        meta: { title: '我的粉丝' }
      },
      {
        path: '/c/user/userCollection',
        component: () => import('@/views/user/userCollection.vue'),
        meta: { title: '我的收藏' }
      },
    ]
  },
  // 设置中心
  {
    path: '/s',
    name: 'settingCenter',
    // 懒加载 动态加载
    component: () => import('@/views/layout/ManageCenter.vue'),
    children: [
      {
        path: '/s/settingCenter/userSetting',
        component: () => import('@/views/user/userSetting/userSetting.vue'),
        meta: { title: '个人设置' }
      },
      {
        path: '/s/settingCenter/publishVideo',
        component: () => import('@/views/file/PublishVideo.vue'),
        meta: { title: '视频上传页' }
      },
      {
        path: '/s/settingCenter/PublishManage',
        component: () => import('@/views/file/PublishManage.vue'),
        meta: { title: '投稿管理' }
      },
    ]
  },

  {
    path: '/video/VideoDetail/:id',
    component: () => import('@/views/video/VideoDetail.vue'),
    meta: { title: '视频详情页2' }
  },

  // 游戏相关
  {
    path: '/protectTheHorse', redirect: '/protectTheHorse/0'
  },
  {
    path: '/protectTheHorse/:id',
    component: () => import('@/components/game/protectTheHorse/index.vue')
  },
  {
    path: '/protectRadish', redirect: '/protectRadish/0'
  },
  {
    path: '/protectRadish/:id',
    component: () => import('@/components/game/protectRadish/index.vue'),
    meta: {
      title: "保卫萝卜4(低配版)"
    }
  },
]

const router = new VueRouter({
  // 防止url中带/#/
  mode: 'history',
  routes
})

export default router
